package org.spamforces.dao.impl;

import org.spamforces.dao.EmailPropertiesDao;
import org.spamforces.model.EmailProperties;

import java.io.ByteArrayInputStream;
import java.util.Properties;

/**
 * @author IvanPopelyshev (ivan.popelyshev@gmail.com)
 */
public class EmailPropertiesDaoImpl extends ApplicationDaoImpl<EmailProperties>
        implements EmailPropertiesDao {

    @Override
    public Properties getDefault() {
        try {
            EmailProperties ep = super.findAll().get(0);
            Properties props = new Properties();
            props.load(new ByteArrayInputStream(ep.getProperties().getBytes()));
            ep.getProperties();
            return props;
        } catch (Exception e) {
            return null;
        }
    }
}
